package request

import "ruoyi-go-echo-ddd/internal/domain/model"

type SysMenuResourcesReq struct {
	CommonPageParam
}

type MenuResourcesInsert struct {
	MenuId int64  `json:"menuId" validate:"required"`
	Method string `json:"method" validate:"required,omitempty,oneof=post get put delete option"`
	Url    string `json:"url" validate:"required,url"`
	Email  string `json:"email" validate:"required,email"`
	Role   string `json:"role" validate:"omitempty,oneof=user admin"`
}

type MenuResourcesUpdate struct {
	ResourceId int64  `json:"resourceId" validate:"required"`
	MenuId     int64  `json:"menuId" validate:"required"`
	Method     string `json:"method" validate:"required"`
	Url        string `json:"url" validate:"required"`
}

func MenuResourcesInsertConvertModel(param *MenuResourcesInsert) *model.SysMenuResources {
	return &model.SysMenuResources{
		MenuId:        param.MenuId,
		RequestMethod: param.Method,
		RequestUrl:    param.Url,
	}
}

func MenuResourcesUpdateConvertModel(param *MenuResourcesUpdate) *model.SysMenuResources {
	return &model.SysMenuResources{
		Id:            param.ResourceId,
		MenuId:        param.MenuId,
		RequestMethod: param.Method,
		RequestUrl:    param.Url,
	}
}


func MenuResourcesInsertSliceConvertModel(slice []*MenuResourcesInsert) []*model.SysMenuResources {
	var list []*model.SysMenuResources
	if (len(slice) > 0) {
		for _,modelInsert := range slice {
			list = append(list, MenuResourcesInsertConvertModel(modelInsert))
		}
	}
	return list
}